﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameBase;
using GameLayer;
using Microsoft.Xna.Framework.Content;
using GameInterface;

namespace GameInstrument
{
    public class Windmill : Button, ICollision<Sprite>
    {
        public Windmill(ContentManager content)
        {
            Sprite type0 = new Sprite(content, "Images/Sprites/Windmill/Down/Down_", 12);
            Sprite type1 = new Sprite(content, "Images/Sprites/Windmill/DownLeft/DownLeft_", 12);
            Sprite type2 = new Sprite(content, "Images/Sprites/Windmill/DownRight/DownRight_", 12);
            
            this.Items.AddRange(new Sprite[] {type0,type1,type2});
        }

        public Windmill(List<Sprite> items) 
        {
            this.Items = items;
        }
        protected override void UpdateEntitys(Microsoft.Xna.Framework.GameTime gameTime, object extraData)
        {
            var currentSprite = this.Items[this.Index];
            currentSprite.Update(gameTime);
            currentSprite.NextFrame();
            base.UpdateEntitys(gameTime, extraData);
        }

        protected override void Paint(Microsoft.Xna.Framework.GameTime gameTime, Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, object extraData)
        {
            this.Items[this.Index].Draw(gameTime, spriteBatch, this.Position);
        }

        public bool CollisionWith(Sprite other, bool pixelLevel)
        {
            return this.Items[this.Index].CollisionWith(other,pixelLevel);
        }

        public void SetType(int index)
        {
            this.Index = index;
        }

        public override object Clone()
        {
            var items = this.Items.Select(x => (Sprite)x.Clone()).ToList<Sprite>();
            Windmill newFire = new Windmill(items);
            return newFire;
        }
    }
}